package com.sjzxywlkj.cplife.alipay.conn;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.request.AlipayEcoCplifeCommunityBatchqueryRequest;
import com.alipay.api.request.AlipayEcoCplifeCommunityCreateRequest;
import com.alipay.api.request.AlipayEcoCplifeCommunityDetailsQueryRequest;
import com.alipay.api.request.AlipayEcoCplifeCommunityModifyRequest;
import com.alipay.api.response.AlipayEcoCplifeCommunityBatchqueryResponse;
import com.alipay.api.response.AlipayEcoCplifeCommunityCreateResponse;
import com.alipay.api.response.AlipayEcoCplifeCommunityDetailsQueryResponse;
import com.alipay.api.response.AlipayEcoCplifeCommunityModifyResponse;
import com.sjzxywlkj.cplife.alipay.config.AlipayConfig;
import com.sjzxywlkj.cplife.alipay.request.entity.CommunityBatchquery;
import com.sjzxywlkj.cplife.alipay.request.entity.CommunityCreate;
import com.sjzxywlkj.cplife.alipay.request.entity.CommunityDetailsQuery;
import com.sjzxywlkj.cplife.alipay.request.entity.CommunityModify;

/**
 * 小区操作
 */

public class CommunityConn {

    //创建物业小区
    public static AlipayEcoCplifeCommunityCreateResponse create(CommunityCreate communityCreate, String app_auth_token) throws AlipayApiException {

        AlipayClient alipayClient = AlipayConfig.aClient();
        AlipayEcoCplifeCommunityCreateRequest request = new AlipayEcoCplifeCommunityCreateRequest();
        request.putOtherTextParam("app_auth_token", app_auth_token);
        request.setBizContent(communityCreate.toJson());
        AlipayEcoCplifeCommunityCreateResponse response = alipayClient.execute(request);
        return response;
    }

    //变更物业小区信息
    public static AlipayEcoCplifeCommunityModifyResponse modify(CommunityModify communityModify, String app_auth_token) throws AlipayApiException {
        AlipayClient alipayClient = AlipayConfig.aClient();
        AlipayEcoCplifeCommunityModifyRequest request = new AlipayEcoCplifeCommunityModifyRequest();
        request.putOtherTextParam("app_auth_token", app_auth_token);
        request.setBizContent(communityModify.toJson());
        AlipayEcoCplifeCommunityModifyResponse response = alipayClient.execute(request);
        return response;
    }

    //查询单个物业小区信息
    public static AlipayEcoCplifeCommunityDetailsQueryResponse query(CommunityDetailsQuery communityDetailsQuery, String app_auth_token) throws AlipayApiException {
        AlipayClient alipayClient = AlipayConfig.aClient();
        AlipayEcoCplifeCommunityDetailsQueryRequest request = new AlipayEcoCplifeCommunityDetailsQueryRequest();
        request.putOtherTextParam("app_auth_token", app_auth_token);
        request.setBizContent(communityDetailsQuery.toJson());
        AlipayEcoCplifeCommunityDetailsQueryResponse response = alipayClient.execute(request);
        return response;
    }

    //批量查询支付宝小区编号
    public static AlipayEcoCplifeCommunityBatchqueryResponse batchquery(CommunityBatchquery communityBatchQuery, String app_auth_token) throws AlipayApiException {
        AlipayClient alipayClient = AlipayConfig.aClient();
        AlipayEcoCplifeCommunityBatchqueryRequest request = new AlipayEcoCplifeCommunityBatchqueryRequest();
        request.putOtherTextParam("app_auth_token", app_auth_token);
        request.setBizContent(communityBatchQuery.toJson());
        AlipayEcoCplifeCommunityBatchqueryResponse response = alipayClient.execute(request);
        return response;
    }
}
